﻿{include file="index/header" /}

				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="#">首页</a>
							</li>
							<li class="active">控制台</li>
						</ul>
					</div>

					<div class="page-content">

						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->

								<div class="alert alert-block alert-success">
									<button type="button" class="close" data-dismiss="alert">
										<i class="icon-remove"></i>
									</button>

									<i class="icon-ok green"></i>

									欢迎使用
									<strong class="green">
										Ace后台管理系统
										<small>(v1.2)</small>
									</strong>
									,轻量级好用的后台管理系统模版.
								</div>
								<div class="row">
									<div class="col-xs-12">
										<h3 class="header smaller lighter blue">销售列表</h3>
										<button class="btn btn-primary" onclick="$('#excel').click()">
											<i class="icon-folder-open-alt align-top bigger-125"></i>
											导入销售数据
										</button>
										<div class="table-header">
										</div>
										<div class="table-responsive">
											<table id="sample-table-2" class="table table-striped table-bordered table-hover">
												<thead>
												<tr>
													<th class="center">
														<label>
															<input type="checkbox" class="ace" />
															<span class="lbl"></span>
														</label>
													</th>
													<th>姓名</th>
													<th>电话</th>
													<th class="hidden-480">添加时间</th>
													<th class="hidden-480">状态</th>

													<th>操作</th>
												</tr>
												</thead>

												<tbody>
													{volist name="list" id="vo"}
													<tr>
														<td class="center">
															<label>
																<input type="checkbox" class="ace" />
																<span class="lbl"></span>
															</label>
														</td>
														<td>{$vo.username}</td>
														<td>{$vo.phone}</td>
														<td class="hidden-480">{$vo.add_time}</td>
														<td class="hidden-480">
															<label>


															{if $vo.status==1}
																<input name="switch-field-1" onclick="changeStatus(this)" data-id="{$vo.id}" data-status="{$vo.status}" checked class="ace ace-switch ace-switch-6" type="checkbox" />
															{else/}
																<input name="switch-field-1" onclick="changeStatus(this)" data-id="{$vo.id}" data-status="{$vo.status}" class="ace ace-switch ace-switch-6" type="checkbox" />
															{/if}
																<span class="lbl"></span>
															</label>
														</td>
														<td>
															<!--<a class="blue" href="#">
																<i class="icon-zoom-in bigger-130"></i>
															</a>-->

															<a class="green" href="{:url('saler/edit',['id'=>$vo['id']])}">
																<i class="icon-pencil bigger-130"></i>
															</a>

															<a class="red" href="jsavascript:;" onclick="del(this)" data-id="{$vo.id}" data-username="{$vo.username}">
																<i class="icon-trash bigger-130"></i>
															</a>
														</td>
													</tr>
												{/volist}
												</tbody>
											</table>
										</div>
										<div style="text-align: center">
											{$list->render()}
										</div>
									</div>
								</div>
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->
			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<script src="__STATIC__/assets/js/jquery.min.js"></script>

		<script type="text/javascript">
			window.jQuery || document.write("<script src='__STATIC__/assets/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='__STATIC__/assets/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='__STATIC__/assets/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script>
		<script src="__STATIC__/assets/js/bootstrap.min.js"></script>
		<script src="__STATIC__/assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<!--[if lte IE 8]>
		  <script src="__STATIC__/assets/js/excanvas.min.js"></script>
		<![endif]-->

		<script src="__STATIC__/assets/js/jquery-ui-1.10.3.custom.min.js"></script>
		<script src="__STATIC__/assets/js/jquery.ui.touch-punch.min.js"></script>
		<script src="__STATIC__/assets/js/jquery.slimscroll.min.js"></script>
		<script src="__STATIC__/assets/js/jquery.easy-pie-chart.min.js"></script>
		<script src="__STATIC__/assets/js/jquery.sparkline.min.js"></script>
		<script src="__STATIC__/assets/js/flot/jquery.flot.min.js"></script>
		<script src="__STATIC__/assets/js/flot/jquery.flot.pie.min.js"></script>
		<script src="__STATIC__/assets/js/flot/jquery.flot.resize.min.js"></script>

		<!-- ace scripts -->

		<script src="__STATIC__/assets/js/ace-elements.min.js"></script>
		<script src="__STATIC__/assets/js/ace.min.js"></script>

		<!-- inline scripts related to this page -->
<input type="file" style="display: none" id="excel"  value="" onchange="upExcel()">
<script>
	function upExcel(){
		var formData=new FormData();
		formData.append("file", document.getElementById("excel").files[0]);
		$.ajax({
			type: "POST",//方法类型
			url:"{:url('saler/inputExcel')}",//url
			data: formData,
			contentType: false,
			processData: false,
			success: function (result) {
				if (result.code == 1) {
					var content='共导入：'+result.data.all+"条数据 成功："+result.data.end+"条";
					alert(content);
					if(result.data.filename){
						window.location.href=result.data.filename
					}

				};
			},
			error: function () {
				alert("异常！");
			}
		});
	}

	function changeStatus(vs){
		var id=$(vs).data('id');
		var n_status=$(vs).data('status');
		if(n_status==1){
			var status=2;
		}else{
			var status=1;
		}
		$.ajax({
			url:"{:url('setStatus')}",
			type:"POST",
			data:{id:id,status:status},
			success:function (res){
				if(res.code==1){
					alert('修改成功');
				}else{
					alert('修改失败');
					window.location.reload();
				}

			}
		})
	}
	function del(vd)
	{
		var id=$(vd).data('id');
		var username=$(vd).data('username');
		if(confirm("是否删除"+username+"?")){
			$.ajax({
				url:"{:url('del')}",
				type:"POST",
				data:{id:id},
				success:function (res){
					if(res.code==1){
						alert('删除成功');
						window.location.reload();
					}else{
						alert('删除失败');

					}

				}
			})
		}
	}

</script>
</body>
</html>

